package com.example.demo.Services.impl;

import com.example.demo.Services.UserSevices;
import com.example.demo.utils.SqlHelper;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import java.sql.*;

@Component
public class UserServicesImpl implements UserSevices {
    Connection conn;
    Statement st;
    ResultSet rs;
    PreparedStatement ps;
    SqlHelper sqlHelper=new SqlHelper();
    private Logger log=Logger.getLogger(this.getClass());
    @Override
    public String selectPWd(String username) {
        String psd="";
        conn=sqlHelper.getConnection();
        String sql="select psw from tb_crpt where crptnam='"+username+"'";
        try {
            st=conn.createStatement();
            rs=st.executeQuery(sql);
            if (rs.next()){
                psd=rs.getString("psw");
            }
            sqlHelper.colse(conn,st,ps,rs);
        } catch (SQLException e) {
            log.error(username+"------------"+e.getMessage());
        }
        return psd;
    }


}
